package cn.jkgly.exam.controller;

import cn.jkgly.exam.entity.CjglBean;
import cn.jkgly.exam.entity.SjxxBean;
import cn.jkgly.exam.entity.TkglBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RequestMapping("/exam")
@Controller
public class ExamController {

    @RequestMapping("/")
    public String exam(HttpServletRequest request) {
        SjxxBean sjxx = new SjxxBean();
        sjxx.setKstime("10");//考试时长，单位是分钟
        sjxx.setSjname("demo");
        ArrayList<SjxxBean> sjxxList = new ArrayList<SjxxBean>();
        sjxxList.add(sjxx);

        List<TkglBean> dxtList = null;
//        dxtList = examservice.selectBySql(dxtSql);
        // 单选题
        String strXzt = "";
        for (int i = 0; i < dxtList.size(); i++) {
            strXzt = strXzt + dxtList.get(i).getIid() + ",";
        }
        if (strXzt.length() > 0) {
            strXzt = strXzt.substring(0, strXzt.length() - 1);
        }



        CjglBean cjglbean = new CjglBean();
        // 试卷ID
        cjglbean.setSjid(sjxxList.get(0).getIid());
        // 学员ID
//        cjglbean.setXyid(Integer.parseInt(userId));
        // 试卷单选题
        cjglbean.setSjdxt(strXzt);
//        int cjb = examservice.insertCjgl(cjglbean);
//        cjglId = cjglbean.getIid();

        request.setAttribute("sjxxList", sjxxList);
        request.setAttribute("dxtList", dxtList);
//        request.setAttribute("cjglId", cjglId);

        return "/exam";
    }
}
